﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ttifa.Infrastructure;
using Ttifa.Infrastructure.Extensions;

namespace Ttifa.WebApi
{
    public class JZBMessage
    {
        /// <summary>
        /// 通讯报文头
        /// </summary>
        public string CommunicationHead { get; set; }
        /// <summary>
        /// 业务报文头
        /// </summary>
        public string BusinessHead { get; set; }
        /// <summary>
        /// 业务内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 分割响应报文
        /// </summary>
        /// <param name="resp"></param>
        /// <returns></returns>
        public static JZBMessage ParseResponse(string resp)
        {
            var msg = new JZBMessage();
            msg.CommunicationHead = resp.ByteSubstring(0, 222);
            msg.BusinessHead = resp.ByteSubstring(222, 122);
            msg.Content = resp.ByteSubstring(222 + 122);

            return msg;
        }

    }
}